package org.tulkas.selector;

import java.util.Comparator;

/**
 * @author <a href="mailto:tulkas.web@gmail.com">Tulkas</a>
 *
 */
public class FilterComparator implements Comparator<Filter> {
	private boolean descent = false;

	public FilterComparator() {
	}

	public FilterComparator(boolean descent) {
		this.descent = descent;
	}

	@Override
	public int compare(Filter o1, Filter o2) {
		if (o1.getPriority() < o2.getPriority()) {
			return descent ? 1 : -1;
		} else if (o1.getPriority() > o2.getPriority()) {
			return descent ? -1 : 1;
		} else {
			return 0;
		}
	}
}
